export const evaluate = {
  /**
   * 动态执行条件表达式
   * @param condition 条件表达式
   * @param data 数据数组
   * @param paramNames 参数名称数组
   * @returns 执行结果
   */
  evaluateCondition: (
    condition: string,
    data: unknown[],
    paramNames: string[] = ['row'],
  ): unknown => {
    if (!condition) return
    const conditionStr = condition.indexOf('return') === -1 ? `return ${condition}` : condition
    const func = new Function(paramNames.join(', '), conditionStr)
    return func(...data)
  },
}
